package com.gwc.schedule.dao.impl;

import com.gwc.schedule.dao.BaseDao;
import com.gwc.schedule.dao.SysUserDao;
import com.gwc.schedule.pojo.SysUser;

import java.util.List;

public class SysUserDaoImpl extends BaseDao implements SysUserDao {
    @Override
    public int addSysUser(SysUser sysUser) {
        String sql = "insert into sys_user values(default,?,?)";
        int rows = baseUpdate(sql, sysUser.getUsername(), sysUser.getUserPwd());
        return rows;
    }

    @Override
    public List<SysUser> findAll() {
        String sql = "select uid, username, uer_pwd userPwd from sys_user";
        List<SysUser> sysUsers = baseQuery(SysUser.class, sql);
        return sysUsers;
    }

    @Override
    public List<SysUser> findByUsername(String username) {
        String sql = "select uid, username, uer_pwd userPwd from sys_user where username = ?";
        List<SysUser> sysUserList = baseQuery(SysUser.class, sql, username);
        return sysUserList;
    }
}
